package com.guoyh.pronet.service.login

import com.guoyh.baserepos.entity.app.UserBean
import com.guoyh.pronet.service.BaseService
import com.guoyh.xprodatas.ktx.addParams
import rxhttp.IAwait
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse
import java.util.*

/**
 * @CreateDate: 2021/8/24 5:27 下午
 * @Author: guoyh
 * @Description: java类作用描述
 */


val loginApi by lazy {
    LoginApiService.instance
}

class LoginApiService private constructor() : BaseService() {
    companion object {
        const val LOGIN_LOGIN = "user/login"
        const val LOGIN_REGISTER = "user/register"

        val instance: LoginApiService by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
            LoginApiService()
        }
    }

    /**
     * 获取列表信息
     */
    fun login(vararg params: Pair<String, Any>): IAwait<UserBean> =
        RxHttp
            .postForm(LOGIN_LOGIN)
            .addParams(*params)
            .toResponse()

    /**
     * 获取首页Banner
     */
    fun register(vararg params: Pair<String, Any>): IAwait<UserBean> =
        RxHttp
            .postForm(LOGIN_REGISTER)
            .addParams(*params)
            .toResponse()

}